﻿<%@ Page Language="C#" MasterPageFile="../Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="Microsoft.Web.Mvc"%>
<asp:Content ID="indexHead" ContentPlaceHolderID="head" runat="server">
    <% string[] Bill = (string[])ViewData["Bill"]; %>
    <title><% = Bill[0]  %></title>
</asp:Content>

<asp:Content ID="css_js" ContentPlaceHolderID="js_css" runat="server">
</asp:Content>

<asp:Content ID="head_content" ContentPlaceHolderID="head_content" runat="server">
    <% Html.RenderAction("index","head"); %>
</asp:Content>

<asp:Content ID="indexContentRight" ContentPlaceHolderID="main_content" runat="server">
 <div class="breadcrumb">
   <% string[] Bill = (string[])ViewData["Bill"]; %>
    <a href="/admin/home">Home</a>:: <a href="/admin/billrent">Danh sách đơn hàng Thuê</a>:: <a href="/admin/billrentdetail?bid=<% = ViewData["bill_id"].ToString()  %>"><% = Bill[0]  %></a>
</div>
<div class="box">

	 <script type="text/javascript">
		function PrintElem(elem)
		{
			Popup($(elem).html());
		}

		function Popup(data) 
		{
			var mywindow = window.open('', 'Chi tiết đơn hàng', 'height=400,width=800');
			mywindow.document.write('<html><head><title>Chi tiết đơn hàng</title>');
			/*optional stylesheet*/ mywindow.document.write('<link rel="stylesheet" type="text/css" href="css/stylesheet.css">');
			mywindow.document.write('</head><body >');
			mywindow.document.write(data);
			mywindow.document.write('</body></html>');
			mywindow.document.close();
			mywindow.print();
			return true;
		}
	</script>
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1 style="background-image: url('image/order.png');">Chi tiết đơn hàng</h1>
	<div class="buttons">
	<form action="/admin/billrentdetail/updatestatus?bid=<% = ViewData["bill_id"].ToString() %>" method="post" id="form" style="float:left;margin-right:10px;margin-top:3px;">
		<select name="status">
                <option value="1" <% if (Bill[11] == "1"){ %> selected = "selected"<% } %>>Mới</option>
                <option value="2" <% if (Bill[11] == "2"){ %> selected = "selected"<% } %>>Đang xử lý</option>
				<option value="3" <% if (Bill[11] == "3"){ %> selected = "selected"<% } %>>Hoàn Thành</option>
				<option value="4" <% if (Bill[11] == "4"){ %> selected = "selected"<% } %>>Huỷ</option>
        </select>
	</form>
	<a onclick="$('#form').submit();" class="button" style="float:left;"><span>Cập Nhật</span></a><a onclick="PrintElem('#printarea')" class="button" style="float:right;"><span>In Hoá Đơn</span></a></div>
  </div>
  <div class="content">
		<% if (Convert.ToInt32(ViewData["success"]) == 1)
     {%><div class="success">Thao tác thành công</div><%}else if(Convert.ToInt32(ViewData["success"]) == 2) {%>
        <div class="warning">Có lỗi trong quá trình thao tác</div>
  <% } %>
	    <div style="display: inline-block; width: 100%; margin-bottom: 15px; clear: both;">
	
    <div id="printarea">
      <div style="background: #547C96; color: #FFF; border-bottom: 1px solid #8EAEC3; padding: 5px; font-size: 14px; font-weight: bold;">Chi tiết đơn hàng</div>
      <div style="background: #FCFCFC; border: 1px solid #8EAEC3; padding: 10px;">


	  <div style="float: left;width:35%">
        <table class="list" >
			<thead>
            <tr>
              <td class="left" style="width:130px;">Mã Đơn Hàng</td>
              <td class="right" style="background: #FFFFFF;"><% = Bill[0] %></td>
			</tr>
			<tr>
              <td class="left">Người Mua</td>
              <td class="right" style="background: #FFFFFF;"><% = Bill[1] %></td>
            </tr>
			<tr>
              <td class="left">Người Nhận</td>
              <td class="right" style="background: #FFFFFF;"><% = Bill[2] %></td>
            </tr>
			<tr>
              <td class="left">Địa Chỉ</td>
              <td class="right" style="background: #FFFFFF;"><% = Bill[3] %></</td>
            </tr>
			<tr>
              <td class="left">Số Điện Thoại</td>
              <td class="right" style="background: #FFFFFF;"><% = Bill[4] %></td>
            </tr>
            <tr>
              <td class="left">Email</td>
              <td class="right" style="background: #FFFFFF;"><% = Bill[5] %></td>
            </tr>			
			
          </thead>
          
        </table>
		</div>
		<div style="float: left;width:20%">&nbsp</div>
		<div style="float: left;width:45%">
	  <table class="list" >
			<thead>
			<tr>
              <td class="left" style="width:200px;">Phương Thức Thanh Toán</td>
              <td class="right" style="background: #FFFFFF;"><% = Bill[6] %></td>
            </tr>
			<tr>
              <td class="left">Phương Thức Vận Chuyển</td>
              <td class="right" style="background: #FFFFFF;"><% = Bill[7] %></td>
            </tr>
			<tr>
              <td class="left">Giá Vận Chuyển</td>
              <td class="right" style="background: #FFFFFF;"><% = Bill[8] %> VNĐ</td>
            </tr>
            <tr>
              <td class="left">Số Lượng Sách</td>
              <td class="right" style="background: #FFFFFF;"><% = Bill[9] %> </td>
            </tr>	
			<tr>
			<tr>
              <td class="left">Tiền Đặt Cọc</td>
              <td class="right" style="background: #FFFFFF;"><% = Bill[12] %> VNĐ </td>
            </tr>	
			<tr>
              <td class="left">Tổng Tiền Thanh Toán</td>
              <td class="right" style="background: #FFFFFF;"><% = Bill[10] %> VNĐ</td>
            </tr>			
          </thead>
          
        </table>
		</div>
		<div style="clear:both;"></div>
	  <table class="list">
          <thead>
            <tr>
              <td class="left">Tên Sách</td>
              <td class="left">Giá Bán</td>
              <td class="left">Số Lượng</td>
              <td class="left">Ngày Thuê</td>
              <td class="left">Số Lượng Ngày Thuê</td>
              <td class="left">Ngày Hết Hạn</td>
              <td class="left">Thành Tiền</td>
            </tr>
          </thead>
          <tbody>
          <% string[][] BillDetail = (string[][])ViewData["Bill_Detail"];%>
          <% int tong = 0; %>
          <% foreach (string[] detail in BillDetail)
             { %>
             <% if (detail == null) break; %>
             <tr>
              <td class="left"><% = detail[0] %></td>
              <td class="left"><% = detail[1] %> VNĐ</td>
              <td class="left"><% = detail[2] %></td>
              <td class="left"><% = detail[5] %></td>
              <td class="left"><% = detail[3] %></td>
              <td class="left"><% = detail[6] %></td>
              <td class="left"><% = detail[4] %> VNĐ</td>
              <% tong += Convert.ToInt32(detail[4].ToString()); %>
            </tr>
            <%} %>
            <tr>
              <td class="left"></td>
              <td class="left"></td>
              <td class="left"></td>
               <td class="left"></td>
               <td class="left"></td>
              <td class="left"> Tổng Cộng :</td>
              <td class="left">  <% =tong.ToString() %>  VNĐ</td>
              
             
            </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>
<!--[if IE]>
<script type="text/javascript" src="view/javascript/jquery/flot/excanvas.js"></script>
<![endif]-->
<script type="text/javascript" src="thongke_files/jquery.js"></script>
<script type="text/javascript"><!--
function getSalesChart(range) {
	$.ajax({
		type: 'GET',
		url: 'index.php?route=common/home/chart&token=e269cfcd438e75a3457129447b704eee&range=' + range,
		dataType: 'json',
		async: false,
		success: function(json) {
			var option = {	
				shadowSize: 0,
				lines: { 
					show: true,
					fill: true,
					lineWidth: 1
				},
				grid: {
					backgroundColor: '#FFFFFF'
				},	
				xaxis: {
            		ticks: json.xaxis
				}
			}

			$.plot($('#report'), [json.order, json.customer], option);
		}
	});
}

getSalesChart($('#range').val());
//--></script>
</div>
</asp:Content>
